package cn.edu.ecut.se2024.controller;

import cn.edu.ecut.se2024.model.Purchase_Report.CostAnalysis;
import cn.edu.ecut.se2024.model.Purchase_Report.PurchaseReport;
import cn.edu.ecut.se2024.model.Purchase_Report.SupplierPerformance;
import cn.edu.ecut.se2024.service.Purchase_ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;

import static cn.edu.ecut.se2024.controller.AuthorizedController.SYS_MAIN_PAGE;

@Controller
public class Purchase_ReportController {
    @Autowired
    private Purchase_ReportService purchase_ReportService;

    @RequestMapping(value = "/report1", method = RequestMethod.GET)
    public String report1(Model model) {
        // 创建一个PurchaseReport对象的集合
        List<PurchaseReport> reports = purchase_ReportService.PurchaseReportService();


        // 将reports集合添加到模型中
        model.addAttribute("reports", reports);

        // 返回视图名称
        return SYS_MAIN_PAGE;
    }

    @RequestMapping("/showreport2")
    public String showreport2(Model model) {
        // 创建并填充 CostAnalysis 集合
        List<CostAnalysis> costAnalyses = purchase_ReportService.CostAnalysisService();

        // 将 CostAnalysis 集合添加到模型中
        model.addAttribute("costAnalyses", costAnalyses);

        // 返回视图名称
        return SYS_MAIN_PAGE;
    }

    @RequestMapping("/showreport3")
    public String showreport3(Model model) {
        // 创建并填充 SupplierPerformance 集合
        List<SupplierPerformance> supplierPerformances = purchase_ReportService.SupplierPerformanceService();

        // 将 SupplierPerformance 集合添加到模型中
        model.addAttribute("supplierPerformances", supplierPerformances);

        // 返回视图名称
        return SYS_MAIN_PAGE;
    }
}
